import ajax from "./ajax";
const BASE = "";

export const reqLogin = (username, password) =>
  ajax(BASE + "/login", { username, password }, "POST");


export const reqCategorys=(parentId)=>ajax("/manage/category/list",{parentId})

// 修改分类
export const reqUpdataCategory=(categoryId,categoryName)=>
ajax("/manage/category/update",{categoryId,categoryName},"POST")

//添加分类
export const reqAddCategory=(parentId,categoryName)=>
ajax("/manage/category/add",{parentId,categoryName},"POST")


//获取用户模块
export const reqUsers=()=>ajax("/manage/user/list");

//删除用户
export const reqDeleteUser=(userId)=>ajax("/manage/user/delete",{userId},"POST")

//添加或者修改用户
export const reqAddOrUpdataUser=(user)=>ajax("/manage/user/"+(user._id?"update":"add"),user,"POST")

// 获取全部角色
export const reqRoles=()=>ajax("/manage/role/list")

// 添加角色
export const reqAddRole=(roleName)=>ajax("/manage/role/add",{roleName},"POST")

//设置权限
export const reqUpdateRole=(role)=>ajax("/manage/role/update",role,"POST")

//获取商品分页列表
export const reqGetProducts=(pageNum=1,pageSize=10)=>ajax("/manage/product/list",{pageNum,pageSize})

// 对商品进行上架下架
export const reqUpOrDownProduct=(productId,status)=>ajax("/manage/product/updateStatus",{productId,status},"POST")